<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="楼凤名" prop="phoenixName">
        <el-input
          v-model="queryParams.phoenixName"
          placeholder="请输入楼凤名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="楼凤类型" prop="phoenixType">
        <el-select v-model="queryParams.phoenixType" placeholder="请选择楼凤类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
          <el-option label="楼凤" value="楼凤" />
          <el-option label="洗浴" value="洗浴" />
          <el-option label="会所" value="会所" />
          <el-option label="外围" value="外围" />
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" prop="phoenixTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.phoenixTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['xqsp:service:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="serviceList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="楼凤id" align="center" prop="phoenixId" />
      <el-table-column label="楼凤名" align="center" prop="phoenixName" />
      <el-table-column label="标题信息" align="center" prop="phoenixTitle" />
      <el-table-column label="楼凤类型" align="center" prop="phoenixType" />
      <el-table-column label="楼凤数量" align="center" prop="phoenixNumber" />
      <el-table-column label="楼凤年龄" align="center" prop="phoenixAge" />
      <el-table-column label="楼凤职务" align="center" prop="phoenixWork" />
      <el-table-column label="服务项目" align="center" prop="phoenixServicesAvailable" />
      <el-table-column label="楼凤价格" align="center" prop="phoenixPrice" />
      <el-table-column label="楼凤服务时间" align="center" prop="phoenixServiceTime" />
      <el-table-column label="楼凤地址" align="center" prop="phoenixAddress" />
      <el-table-column label="楼凤详情介绍" align="center" prop="phoenixDetails" />
      <el-table-column label=" 楼凤评分" align="center" prop="phoenixScore" />
      <el-table-column label="楼凤联系方式" align="center" prop="phoenixPhone" />
      <el-table-column label="楼凤详细地址" align="center" prop="phoenixDetailedAddress" />
      <el-table-column label="楼凤观看人数" align="center" prop="phoenixWatchNumber" />
      <el-table-column label="楼凤点赞人数" align="center" prop="phoenixLikeNumber" />
      <el-table-column label="解锁金币数" align="center" prop="phoenixUnlockGold" />
      <el-table-column label="楼凤上传图片" align="center" prop="phoenixImg">
        <template slot-scope="scope">
          <el-image :src="scope.row.phoenixImg"  :preview-src-list="[scope.row.phoenixImg]" style="width: 100px;height: 100px"/>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="phoenixTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.phoenixTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['xqsp:service:edit']"
          >同意</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['xqsp:service:remove']"
          >拒绝</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />



  </div>
</template>

<script>
  import { listServiceAudit, getService, delService, addService, updateService, exportService,updateServiceState ,updateServiceAudit} from "@/api/xqsp/service";


  export default {
    name: "Service",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 楼凤操作表格数据
        serviceList: [],
        //楼凤评价
        evaluationList:[],
        // 弹出层标题
        title: "",

        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          phoenixName: null,
          phoenixTitle: null,
          phoenixType: null,
          phoenixNumber: null,
          phoenixAge: null,
          phoenixWork: null,
          phoenixServicesAvailable: null,
          phoenixPrice: null,
          phoenixServiceTime: null,
          phoenixAddress: null,
          phoenixDetails: null,
          phoenixScore: null,
          phoenixWatchNumber: null,
          phoenixLikeNumber: null,
          phoenixUnlockGold: null,
          phoenixImg: null,
          phoenixState: null,
          phoenixAudit: null,
          phoenixTime: null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询楼凤操作列表 */
      getList() {
        this.loading = true;
        listServiceAudit(this.queryParams).then(response => {
          this.serviceList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          phoenixId: null,
          phoenixName: null,
          phoenixTitle: null,
          phoenixType: null,
          phoenixNumber: null,
          phoenixAge: null,
          phoenixWork: null,
          phoenixServicesAvailable: null,
          phoenixPrice: null,
          phoenixServiceTime: null,
          phoenixAddress: null,
          phoenixDetails: null,
          phoenixScore: null,
          phoenixWatchNumber: null,
          phoenixLikeNumber: null,
          phoenixUnlockGold: null,
          phoenixImg: null,
          phoenixState: null,
          phoenixAudit: null,
          phoenixTime: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.phoenixId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },

      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const phoenixId = row.phoenixId
        const phoenixAudit=1
        updateService(phoenixId,phoenixAudit).then(response => {
          this.msgSuccess("已同意");
          this.getList();
        });
      },

      /** 删除按钮操作 */
      handleDelete(row) {
        const phoenixIds = row.phoenixId || this.ids;
        this.$confirm('是否确认拒绝楼凤"' + row.phoenixName + '"的申请?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delService(phoenixIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("拒绝成功");
        })
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有楼凤操作数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportService(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
      },



    }
  };
</script>
